import subprocess
class ssh_client:
    def sshClient(host, port, user, password, command):
        '''
        Function to connect to ssh server
        with given host, port, user, password and command
        and execute the command
        '''
        ssh = subprocess.Popen(["sshpass", "-p", password,
                                "ssh", "-p", port, user + "@" + host, command],
                               stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout, stderr = ssh.communicate()
        if stderr:
            print("Error: {}".format(stderr))
        else:
            print("Command success to IP : {}".format(host))
